Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devlin Lynch #4

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

devklynch
Copy link

No description provided.

:price
def initialize(item_info)
@name = item_info[:name]
@price = price_to_float(item_info[:price])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!!

@@ -1,3 +1,13 @@
class Item
attr_reader :name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great git commit history!


def vendors_that_sell(item)
vendor_list = @vendors.find_all do |vendor|
vendor.inventory.include?(item)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great use of built in methods


def total_inventory
inventory = {}
@vendors.each do |vendor|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is probably an easier way to write this method! Could be worth asking chatgpt for refactor tips.


@market.add_vendor(@vendor2)
@market.add_vendor(@vendor3)
expect(@market.vendors).to eq([@vendor1,@vendor2,@vendor3])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love that you expect this works for one vendor, and multiples

expect(@vendor.inventory.keys).to eq([@item1])

@vendor.stock(@item2,20)
expect(@vendor.inventory.keys).to eq([@item1,@item2])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stock is tested in isolation - nice!

item_totals ={}
@vendors.each do |vendor|
vendor.inventory.each do |item,quantity|
if item_totals[item] == nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great conditional logic checking the state of your hash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants